package com.example.javabase.DesignPattern.Strategy;

import org.apache.logging.log4j.util.Strings;

public enum InstrCalculateEnum {
    YEAR_MONTH_API(1, "yearMonthApiCalculateHandler"),
    YEAR_AVG_API(2, "yearAvgApiCalculateHandler"),
    SCRIPT_API(3, "scriptApiCalculateHandler");

    private Integer type;
    private String beanName;

    InstrCalculateEnum(Integer type, String beanName) {
        this.type = type;
        this.beanName = beanName;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getBeanName() {
        return beanName;
    }

    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }

    public static String getClassName(Integer type) throws Exception {
        String beanName = null;
        for (InstrCalculateEnum msgCallBackStrategyEnum : InstrCalculateEnum.values()) {
            if (msgCallBackStrategyEnum.type.equals(type)) {
                beanName = msgCallBackStrategyEnum.getBeanName();
                break;
            }
        }
        if(Strings.isEmpty(beanName)){
            throw new Exception("未匹配到指标计算策略...");
        }
        return beanName;
    }
}
